package o;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.SubMenu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleRes;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.RecyclerView.s;
import com.google.android.material.internal.NavigationMenuItemView;
import com.google.android.material.internal.NavigationMenuView;
import com.google.android.material.internal.ParcelableSparseArray;
import java.util.ArrayList;

@RestrictTo({androidx.annotation.RestrictTo.d.LIBRARY_GROUP})
public class asc implements bn {
    Drawable ʻ;
    private int ʻॱ;
    ColorStateList ʼ;
    boolean ʽ;
    int ˊ;
    final OnClickListener ˊॱ = new OnClickListener(this) {
        final /* synthetic */ asc ॱ;

        {
            this.ॱ = r1;
        }

        public void onClick(View view) {
            NavigationMenuItemView navigationMenuItemView = (NavigationMenuItemView) view;
            this.ॱ.ˏ(true);
            bj ˏ = navigationMenuItemView.ˏ();
            boolean ˊ = this.ॱ.ˋ.ˊ(ˏ, this.ॱ, 0);
            if (ˏ != null && ˏ.isCheckable() && ˊ) {
                this.ॱ.ˎ.ˊ(ˏ);
            }
            this.ॱ.ˏ(false);
            this.ॱ.ˊ(false);
        }
    };
    bd ˋ;
    int ˋॱ;
    b ˎ;
    LayoutInflater ˏ;
    private o.bn.d ˏॱ;
    int ͺ;
    LinearLayout ॱ;
    private NavigationMenuView ॱˊ;
    int ॱॱ;
    private int ॱᐝ;
    ColorStateList ᐝ;

    interface a {
    }

    class b extends androidx.recyclerview.widget.RecyclerView.a<j> {
        private final ArrayList<a> ˊ = new ArrayList();
        final /* synthetic */ asc ˎ;
        private bj ˏ;
        private boolean ॱ;

        public /* synthetic */ s ˎ(ViewGroup viewGroup, int i) {
            return ˏ(viewGroup, i);
        }

        public /* synthetic */ void ˏ(s sVar) {
            ˋ((j) sVar);
        }

        public /* synthetic */ void ॱ(s sVar, int i) {
            ˋ((j) sVar, i);
        }

        b(asc o_asc) {
            this.ˎ = o_asc;
            ʼ();
        }

        public long ˏ(int i) {
            return (long) i;
        }

        public int ˏ() {
            return this.ˊ.size();
        }

        public int ˎ(int i) {
            a aVar = (a) this.ˊ.get(i);
            if (aVar instanceof c) {
                return 2;
            }
            if (aVar instanceof d) {
                return 3;
            }
            if (!(aVar instanceof g)) {
                throw new RuntimeException("Unknown item type.");
            } else if (((g) aVar).ˊ().hasSubMenu()) {
                return 1;
            } else {
                return 0;
            }
        }

        public j ˏ(ViewGroup viewGroup, int i) {
            switch (i) {
                case 0:
                    return new i(this.ˎ.ˏ, viewGroup, this.ˎ.ˊॱ);
                case 1:
                    return new f(this.ˎ.ˏ, viewGroup);
                case 2:
                    return new h(this.ˎ.ˏ, viewGroup);
                case 3:
                    return new e(this.ˎ.ॱ);
                default:
                    return null;
            }
        }

        public void ˋ(j jVar, int i) {
            switch (ˎ(i)) {
                case 0:
                    NavigationMenuItemView navigationMenuItemView = (NavigationMenuItemView) jVar.ˊ;
                    navigationMenuItemView.ˏ(this.ˎ.ᐝ);
                    if (this.ˎ.ʽ) {
                        navigationMenuItemView.setTextAppearance(this.ˎ.ˊ);
                    }
                    if (this.ˎ.ʼ != null) {
                        navigationMenuItemView.setTextColor(this.ˎ.ʼ);
                    }
                    ViewCompat.ˏ(navigationMenuItemView, this.ˎ.ʻ != null ? this.ˎ.ʻ.getConstantState().newDrawable() : null);
                    g gVar = (g) this.ˊ.get(i);
                    navigationMenuItemView.setNeedsEmptyIcon(gVar.ˋ);
                    navigationMenuItemView.setHorizontalPadding(this.ˎ.ॱॱ);
                    navigationMenuItemView.setIconPadding(this.ˎ.ˋॱ);
                    navigationMenuItemView.ॱ(gVar.ˊ(), 0);
                    return;
                case 1:
                    ((TextView) jVar.ˊ).setText(((g) this.ˊ.get(i)).ˊ().getTitle());
                    return;
                case 2:
                    c cVar = (c) this.ˊ.get(i);
                    jVar.ˊ.setPadding(0, cVar.ˋ(), 0, cVar.ˏ());
                    return;
                default:
                    return;
            }
        }

        public void ˋ(j jVar) {
            if (jVar instanceof i) {
                ((NavigationMenuItemView) jVar.ˊ).ˋ();
            }
        }

        public void ॱ() {
            ʼ();
            ˊ();
        }

        private void ʼ() {
            if (!this.ॱ) {
                this.ॱ = true;
                this.ˊ.clear();
                this.ˊ.add(new d());
                int i = -1;
                int i2 = 0;
                boolean z = false;
                int size = this.ˎ.ˋ.ʽ().size();
                int i3 = 0;
                while (i3 < size) {
                    int i4;
                    bj bjVar = (bj) this.ˎ.ˋ.ʽ().get(i3);
                    if (bjVar.isChecked()) {
                        ˊ(bjVar);
                    }
                    if (bjVar.isCheckable()) {
                        bjVar.ॱ(false);
                    }
                    int i5;
                    if (bjVar.hasSubMenu()) {
                        SubMenu subMenu = bjVar.getSubMenu();
                        if (subMenu.hasVisibleItems()) {
                            if (i3 != 0) {
                                this.ˊ.add(new c(this.ˎ.ͺ, 0));
                            }
                            this.ˊ.add(new g(bjVar));
                            Object obj = null;
                            int size2 = this.ˊ.size();
                            int size3 = subMenu.size();
                            for (i5 = 0; i5 < size3; i5++) {
                                bj bjVar2 = (bj) subMenu.getItem(i5);
                                if (bjVar2.isVisible()) {
                                    if (obj == null && bjVar2.getIcon() != null) {
                                        obj = 1;
                                    }
                                    if (bjVar2.isCheckable()) {
                                        bjVar2.ॱ(false);
                                    }
                                    if (bjVar.isChecked()) {
                                        ˊ(bjVar);
                                    }
                                    this.ˊ.add(new g(bjVar2));
                                }
                            }
                            if (obj != null) {
                                ˏ(size2, this.ˊ.size());
                            }
                        }
                        i4 = i;
                    } else {
                        int size4;
                        boolean z2;
                        i5 = bjVar.getGroupId();
                        if (i5 != i) {
                            size4 = this.ˊ.size();
                            z2 = bjVar.getIcon() != null;
                            if (i3 != 0) {
                                size4++;
                                this.ˊ.add(new c(this.ˎ.ͺ, this.ˎ.ͺ));
                            }
                        } else if (z || bjVar.getIcon() == null) {
                            z2 = z;
                            size4 = i2;
                        } else {
                            z2 = true;
                            ˏ(i2, this.ˊ.size());
                            size4 = i2;
                        }
                        g gVar = new g(bjVar);
                        gVar.ˋ = z2;
                        this.ˊ.add(gVar);
                        z = z2;
                        i2 = size4;
                        i4 = i5;
                    }
                    i3++;
                    i = i4;
                }
                this.ॱ = false;
            }
        }

        private void ˏ(int i, int i2) {
            while (i < i2) {
                ((g) this.ˊ.get(i)).ˋ = true;
                i++;
            }
        }

        public void ˊ(bj bjVar) {
            if (this.ˏ != bjVar && bjVar.isCheckable()) {
                if (this.ˏ != null) {
                    this.ˏ.setChecked(false);
                }
                this.ˏ = bjVar;
                bjVar.setChecked(true);
            }
        }

        public Bundle ʻ() {
            Bundle bundle = new Bundle();
            if (this.ˏ != null) {
                bundle.putInt("android:menu:checked", this.ˏ.getItemId());
            }
            SparseArray sparseArray = new SparseArray();
            int size = this.ˊ.size();
            for (int i = 0; i < size; i++) {
                a aVar = (a) this.ˊ.get(i);
                if (aVar instanceof g) {
                    bj ˊ = ((g) aVar).ˊ();
                    View actionView = ˊ != null ? ˊ.getActionView() : null;
                    if (actionView != null) {
                        SparseArray parcelableSparseArray = new ParcelableSparseArray();
                        actionView.saveHierarchyState(parcelableSparseArray);
                        sparseArray.put(ˊ.getItemId(), parcelableSparseArray);
                    }
                }
            }
            bundle.putSparseParcelableArray("android:menu:action_views", sparseArray);
            return bundle;
        }

        public void ˋ(Bundle bundle) {
            a aVar;
            bj ˊ;
            int i = 0;
            int i2 = bundle.getInt("android:menu:checked", 0);
            if (i2 != 0) {
                this.ॱ = true;
                int size = this.ˊ.size();
                for (int i3 = 0; i3 < size; i3++) {
                    aVar = (a) this.ˊ.get(i3);
                    if (aVar instanceof g) {
                        ˊ = ((g) aVar).ˊ();
                        if (ˊ != null && ˊ.getItemId() == i2) {
                            ˊ(ˊ);
                            break;
                        }
                    }
                }
                this.ॱ = false;
                ʼ();
            }
            SparseArray sparseParcelableArray = bundle.getSparseParcelableArray("android:menu:action_views");
            if (sparseParcelableArray != null) {
                i2 = this.ˊ.size();
                while (i < i2) {
                    aVar = (a) this.ˊ.get(i);
                    if (aVar instanceof g) {
                        ˊ = ((g) aVar).ˊ();
                        if (ˊ != null) {
                            View actionView = ˊ.getActionView();
                            if (actionView != null) {
                                ParcelableSparseArray parcelableSparseArray = (ParcelableSparseArray) sparseParcelableArray.get(ˊ.getItemId());
                                if (parcelableSparseArray != null) {
                                    actionView.restoreHierarchyState(parcelableSparseArray);
                                }
                            }
                        }
                    }
                    i++;
                }
            }
        }

        public void ॱ(boolean z) {
            this.ॱ = z;
        }
    }

    static class c implements a {
        private final int ˊ;
        private final int ˋ;

        public c(int i, int i2) {
            this.ˊ = i;
            this.ˋ = i2;
        }

        public int ˋ() {
            return this.ˊ;
        }

        public int ˏ() {
            return this.ˋ;
        }
    }

    static class d implements a {
        d() {
        }
    }

    static abstract class j extends s {
        public j(View view) {
            super(view);
        }
    }

    static class e extends j {
        public e(View view) {
            super(view);
        }
    }

    static class f extends j {
        public f(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            super(layoutInflater.inflate(o.aqu.i.ᐝ, viewGroup, false));
        }
    }

    static class g implements a {
        boolean ˋ;
        private final bj ˎ;

        g(bj bjVar) {
            this.ˎ = bjVar;
        }

        public bj ˊ() {
            return this.ˎ;
        }
    }

    static class h extends j {
        public h(LayoutInflater layoutInflater, ViewGroup viewGroup) {
            super(layoutInflater.inflate(o.aqu.i.ʽ, viewGroup, false));
        }
    }

    static class i extends j {
        public i(LayoutInflater layoutInflater, ViewGroup viewGroup, OnClickListener onClickListener) {
            super(layoutInflater.inflate(o.aqu.i.ॱ, viewGroup, false));
            this.ˊ.setOnClickListener(onClickListener);
        }
    }

    public void ˏ(Context context, bd bdVar) {
        this.ˏ = LayoutInflater.from(context);
        this.ˋ = bdVar;
        this.ͺ = context.getResources().getDimensionPixelOffset(o.aqu.c.ˋॱ);
    }

    public bo ˋ(ViewGroup viewGroup) {
        if (this.ॱˊ == null) {
            this.ॱˊ = (NavigationMenuView) this.ˏ.inflate(o.aqu.i.ʻ, viewGroup, false);
            if (this.ˎ == null) {
                this.ˎ = new b(this);
            }
            this.ॱ = (LinearLayout) this.ˏ.inflate(o.aqu.i.ʼ, this.ॱˊ, false);
            this.ॱˊ.setAdapter(this.ˎ);
        }
        return this.ॱˊ;
    }

    public void ˊ(boolean z) {
        if (this.ˎ != null) {
            this.ˎ.ॱ();
        }
    }

    public void ˎ(o.bn.d dVar) {
        this.ˏॱ = dVar;
    }

    public boolean ˎ(bv bvVar) {
        return false;
    }

    public void ˏ(bd bdVar, boolean z) {
        if (this.ˏॱ != null) {
            this.ˏॱ.ॱ(bdVar, z);
        }
    }

    public boolean ˏ() {
        return false;
    }

    public boolean ˏ(bd bdVar, bj bjVar) {
        return false;
    }

    public boolean ˎ(bd bdVar, bj bjVar) {
        return false;
    }

    public int ॱ() {
        return this.ʻॱ;
    }

    public void ॱ(int i) {
        this.ʻॱ = i;
    }

    public Parcelable ʽ() {
        Parcelable bundle = new Bundle();
        if (this.ॱˊ != null) {
            SparseArray sparseArray = new SparseArray();
            this.ॱˊ.saveHierarchyState(sparseArray);
            bundle.putSparseParcelableArray("android:menu:list", sparseArray);
        }
        if (this.ˎ != null) {
            bundle.putBundle("android:menu:adapter", this.ˎ.ʻ());
        }
        if (this.ॱ != null) {
            sparseArray = new SparseArray();
            this.ॱ.saveHierarchyState(sparseArray);
            bundle.putSparseParcelableArray("android:menu:header", sparseArray);
        }
        return bundle;
    }

    public void ˏ(Parcelable parcelable) {
        if (parcelable instanceof Bundle) {
            Bundle bundle = (Bundle) parcelable;
            SparseArray sparseParcelableArray = bundle.getSparseParcelableArray("android:menu:list");
            if (sparseParcelableArray != null) {
                this.ॱˊ.restoreHierarchyState(sparseParcelableArray);
            }
            Bundle bundle2 = bundle.getBundle("android:menu:adapter");
            if (bundle2 != null) {
                this.ˎ.ˋ(bundle2);
            }
            sparseParcelableArray = bundle.getSparseParcelableArray("android:menu:header");
            if (sparseParcelableArray != null) {
                this.ॱ.restoreHierarchyState(sparseParcelableArray);
            }
        }
    }

    public void ˊ(@NonNull bj bjVar) {
        this.ˎ.ˊ(bjVar);
    }

    public View ˏ(@LayoutRes int i) {
        View inflate = this.ˏ.inflate(i, this.ॱ, false);
        ˊ(inflate);
        return inflate;
    }

    public void ˊ(@NonNull View view) {
        this.ॱ.addView(view);
        this.ॱˊ.setPadding(0, 0, 0, this.ॱˊ.getPaddingBottom());
    }

    public void ˎ(@Nullable ColorStateList colorStateList) {
        this.ᐝ = colorStateList;
        ˊ(false);
    }

    public void ˊ(@Nullable ColorStateList colorStateList) {
        this.ʼ = colorStateList;
        ˊ(false);
    }

    public void ˎ(@StyleRes int i) {
        this.ˊ = i;
        this.ʽ = true;
        ˊ(false);
    }

    public void ॱ(@Nullable Drawable drawable) {
        this.ʻ = drawable;
        ˊ(false);
    }

    public void ˋ(int i) {
        this.ॱॱ = i;
        ˊ(false);
    }

    public void ˊ(int i) {
        this.ˋॱ = i;
        ˊ(false);
    }

    public void ˏ(boolean z) {
        if (this.ˎ != null) {
            this.ˎ.ॱ(z);
        }
    }

    public void ॱ(ij ijVar) {
        int ˎ = ijVar.ˎ();
        if (this.ॱᐝ != ˎ) {
            this.ॱᐝ = ˎ;
            if (this.ॱ.getChildCount() == 0) {
                this.ॱˊ.setPadding(0, this.ॱᐝ, 0, this.ॱˊ.getPaddingBottom());
            }
        }
        ViewCompat.ॱ(this.ॱ, ijVar);
    }
}
